import { defineStore } from 'pinia'
import axios from 'axios'
interface User {
  id: number,
  title: string,
  content: string,
  userid: number,
  username: string,
  tags: [string]
}
export const useArticlesStore = defineStore('articles', {
  state: () => {
    return {
      tableData: <User[]>([])
    }
  },
  actions: {
    async getArticle() {
      const response = await axios.get(`http://192.168.1.3:8000/admin/ReadArticle`)
      return response
    },
    async deleteArticle(token: string, id: number) {
      const response = await axios.delete(`http://192.168.1.3:8000/article/deleteArticle/${id}`,
        { headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } }
      )
      return response
    }
  }
})